package com.nbjtjc.safe.api.sys;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.DeleteGroup;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.sys.SysPost;
import com.nbjtjc.safe.model.sys.SysRole;
import com.nbjtjc.safe.service.sys.SysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther guqianbin
 * @date 2018/8/8 15:40
 * 岗位
 **/
@RestController
@RequestMapping("/post")
@CrossOrigin("*")
public class SysPostController {

    @Autowired
    private SysPostService sysPostService;

    @PostMapping("/add")
    public Result<SysPost> add(SysPost sysPost){
        ValidatorUtils.validateEntity(sysPost);
        Result result=new Result<>();
        result=sysPostService.add(sysPost);
        return result;
    }

    @PostMapping("/delete")
    public Result<SysPost> delete(SysPost sysPost){
        ValidatorUtils.validateEntity(sysPost, DeleteGroup.class);
        Result result=new Result<>();
        result=sysPostService.delete(sysPost);
        return result;
    }
    @PostMapping("/update")
    public Result<SysPost> update(SysPost sysPost){
        ValidatorUtils.validateEntity(sysPost, UpdateGroup.class);
        Result result=new Result<>();
        result=sysPostService.update(sysPost);
        return result;
    }
    @PostMapping("/find")
    public Result<SysPost> find(SysPost sysPost){
        Result result=new Result<>();
        result.setData(sysPostService.find(sysPost));
        return result;
    }
}
